package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86155
 * date: 2024-03-24
 * Time: 19:27
 *
 * 画矩形
 */




class Shape{
    public void draw(){
        System.out.println("画图");
    }
}
class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画矩形");
    }
}
class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("⚪");
    }
}
class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("画一个三角形");
    }
}
public class Test {
    public static void func(Shape shape){
        shape.draw();
    }
    //⚪ 花 矩形 ⚪矩形 ❀
    public static void fun3(){
        Shape[] shapes = {new Rect(),new Cycle(),new Triangle()};
        for (Shape s:shapes) {
            s.draw();
        }
    }
    public static void main(String[] args) {
        fun3();
    }
    public static void main2(String[] args) {

        func(new Rect());
        func(new Cycle());
        func(new Triangle());
    }
    public static void main1(String[] args) {
        Shape shape = new Rect();
        Shape shape2 = new Cycle();
        Shape shape1 = new Triangle();
        shape.draw();
        shape2.draw();
        shape1.draw();
    }
}
